package com.bwie.bill.service.impl;

import com.bwie.bill.mapper.BillMapper;
import com.bwie.bill.service.BillService;
import com.bwie.common.domain.Bill;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：杨鹏
 * @Package：com.bwie.bill.service.impl
 * @Project：billManager
 * @name：BillServiceImpl
 * @Date：2024/7/26 8:42
 */
@Service
public class BillServiceImpl implements BillService {

    @Autowired
    private BillMapper billMapper;

    @Override
    public Result add(Bill bill) {
        // 添加
        Integer i = billMapper.add(bill);
        return i>0?Result.success():Result.error();
    }

    @Override
    public Result selectAll() {
        // 列表查询全部
        List<Bill> billList = billMapper.selectAll();
        System.out.println("表bill里的数据");
        for (Bill bill : billList) {
            System.out.println("序号: "+ bill.getBillId()+" , 账单金额: "+bill.getBillMonery()+" , 账单时间: "+bill.getBillDate() );
        }
        return Result.success(billList);
    }
}
